package LeetcodeTest_forty_three;
//303. 区域和检索 - 数组不可变
public class sumRange
{
    public static void main(String[] args)
    {
        int[] nums={1,2,3,4,6};
        NumArray numArray=new NumArray(nums);
        System.out.println(numArray.sumRange(1,2));
    }
}
class NumArray
{
    private int[] nums;
    public NumArray(int[] nums)
    {
        this.nums=nums;
    }

    public int sumRange(int i, int j)
    {
        int sum=0;
        for(int index1=i;index1<=j;index1++)
        {
            sum+=nums[index1];
        }
        return sum;
    }
}